home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 09 - 1993 / 09.06 Jun 93 / C Shell XCMD / BDisplayOutput.c next >
Encoding:
C/C++ Source or Header  |  1992-09-05  |  4.0 KB  |  178 lines  |  [TEXT/KAHL]

  1. /**************************************************************
  2.  * BDisplayOutput.c
  3.  *
  4.  * SUPERCLASS = BEditDoc
  5.  *
  6.  * Display the contents of a Handle in a text screen.  It requires
  7.  *   a floating window desktop
  8.  * Window resource with id of 500 must be in resource file.
  9.  *
  10.  * © copyright 1991, KSS Scientific Consultants.
  11.  *
  12.  **************************************************************/
  13.  
  14. #include <CApplication.h>
  15. #include <CBureaucrat.h>
  16. #include <CScrollPane.h>
  17. #include <CSwitchboard.h>
  18. #include <CWindow.h>
  19. #include <commands.h>
  20. #include <string.h>
  21. #include "BDisplayOutput.h"
  22. #include "BEditPane.h"
  23.  
  24. #define    WINDculture        500        // Resource ID for WIND template
  25.  
  26. extern CApplication        *gApplication;
  27. extern CBureaucrat        *gGopher;
  28. extern CDesktop            *gDesktop;            // The visible Desktop
  29. //Boolean        BDisplayOutput::fQuitStatus = FALSE;
  30.  
  31. /*****************************************************************
  32.  * IBDisplayOutput()
  33.  *
  34.  * Initialization method.
  35.  *
  36.  ****************************************************************/
  37.     
  38. void BDisplayOutput::IBDisplayOutput(CApplication *anApplication, Boolean printable)
  39. {
  40.     inherited::IEditDoc(anApplication, printable);
  41. }
  42.  
  43. /******************************************************************
  44.  * BuildWindow
  45.  *
  46.  * Override BuildWindow so a floating window is created and it is 
  47.  *   not positioned by the Decorator.
  48.  *
  49.  *******************************************************************/
  50.  
  51. void BDisplayOutput::BuildWindow (Handle theData)
  52.  
  53. {
  54.     CScrollPane        *theScrollPane;
  55.     BEditPane        *theMainPane;
  56.     Rect            margin;
  57.  
  58.     itsWindow = new(CWindow);
  59.     itsWindow->IWindow(WINDculture, TRUE, gDesktop, this);
  60.     itsWindow->Move(40, 60);
  61.     
  62.     theScrollPane = new(CScrollPane);
  63.     
  64.     theScrollPane->IScrollPane(itsWindow, this, 10, 10, 0, 0,
  65.                                 sizELASTIC, sizELASTIC,
  66.                                 TRUE, TRUE, TRUE);
  67.  
  68.     theScrollPane->FitToEnclFrame(TRUE, TRUE);
  69.  
  70.     theMainPane = new(BEditPane);
  71.     itsMainPane = theMainPane;
  72.     itsGopher = theMainPane;
  73.  
  74.     theMainPane->IEditPane(theScrollPane, this);
  75.  
  76.     theScrollPane->InstallPanorama(theMainPane);
  77.  
  78.     if (theData)
  79.         theMainPane->SetTextHandle(theData);
  80.     
  81.     //gDecorator->PlaceNewWindow(itsWindow);
  82. }
  83.  
  84. /**********************************************************
  85.  * EventManagement()
  86.  *
  87.  * Event control loop
  88.  *
  89.  **********************************************************/
  90.  
  91. void BDisplayOutput::EventManagement(void)
  92. {
  93.     SetQuitStatus(FALSE);
  94.     do
  95.     {
  96.         gApplication->itsSwitchboard->ProcessEvent();
  97.     } while (GetQuitStatus() == FALSE);
  98. }
  99.  
  100. /*****************************************************************
  101.  * DisplayRun()
  102.  *
  103.  * Entry method.
  104.  *
  105.  ****************************************************************/
  106.     
  107. void BDisplayOutput::DisplayRun(Handle theText)
  108. {
  109.     long    tempLong;
  110.     
  111.     BuildWindow(0L);
  112.     itsWindow->Select();
  113.  
  114.     tempLong = strlen(*theText);
  115.     SetHandleSize(theText, tempLong);
  116.     ((BEditPane*)itsMainPane)->SetTextHandle(theText);
  117.     
  118.     gGopher = itsGopher;
  119.     EventManagement();
  120.     
  121. }
  122.  
  123. /********************************************************************
  124.  * CloseWind()
  125.  *
  126.  * Add code to change QuitStatus to TRUE
  127.  *
  128.  ********************************************************************/
  129.  
  130. void BDisplayOutput::CloseWind(CWindow *theWindow)
  131. {
  132.     SetQuitStatus(TRUE);
  133.     
  134. }
  135.  
  136. /**********************************************************************
  137.  * DoCommand()
  138.  *
  139.  * Respond to menu.
  140.  *
  141.  *********************************************************************/
  142.  
  143. void BDisplayOutput::DoCommand(long theCommand)
  144. {
  145.     switch (theCommand) 
  146.     {
  147.         case cmdQuit:
  148.             SetQuitStatus(TRUE);
  149.             break;
  150.             
  151.         default:    inherited::DoCommand(theCommand);
  152.                     break;
  153.     }
  154. }
  155.  
  156. /**********************************************************************
  157.  * SetQuitStatus()
  158.  *
  159.  * Set or reset fQuitStatus.
  160.  *
  161.  *********************************************************************/
  162.  
  163. void BDisplayOutput::SetQuitStatus(Boolean status)
  164. {
  165.     fQuitStatus = status;
  166. }
  167.  
  168. /**********************************************************************
  169.  * GetQuitStatus()
  170.  *
  171.  * Get the status fQuitStatus.
  172.  *
  173.  **********************************************************************/
  174.  
  175. Boolean BDisplayOutput::GetQuitStatus(void)
  176. {
  177.     return (fQuitStatus);
  178. }